////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#ifndef __WN_SCRIPTING_LVALUE_H__
#define __WN_SCRIPTING_LVALUE_H__

#include "WNScripting/inc/WNParseNode.h"



namespace WNScripting {

    enum WNLValueType {
        eWNLValueIdentifier,
        eWNLValueArrayAccess,
        eWNLValueStructAccess,
        eWNLValueInvalid
    };

    class WNExpression;

    class WNLValue : public WNParseNode {
    public: 
        WNLValue(WN_SIZE_T _startLine,
                 WN_SIZE_T _endLine,
                 WN_SIZE_T _startChar,
                 WN_SIZE_T _endChar,
                 WNIdentifierElement _identifier);

        WNLValue(WN_SIZE_T _startLine,
                 WN_SIZE_T _endLine,
                 WN_SIZE_T _startChar,
                 WN_SIZE_T _endChar,
                 WNLValue* _lval,
                 WNExpression* _expr);

        WNLValue(WN_SIZE_T _startLine,
                 WN_SIZE_T _endLine,
                 WN_SIZE_T _startChar,
                 WN_SIZE_T _endChar,
                 WNLValue* _lVal,
                 WNIdentifierElement _identifier);


        virtual ~WNLValue();
        virtual llvm::Value* OptimizeAndGenerate(WNScriptingEngineData& _scriptingData, WNFunctionDecl* _functionDecl);
        WNTypeElement GetOutType();

    private:
        WNIdentifierElement mIdentifier;
        WNLValue* mLValue;
        WNExpression* mExpression;
        WNLValueType mType;
        WNTypeElement mOutType;
    };
}
#endif // __WN_SCRIPTING_LVALUE_H__